home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 157_01 / qedpcio.a < prev    next >
Text File  |  1987-10-10  |  7KB  |  261 lines

  1. ;    PCIO.A    --    Screen and keyboard interface routines for the PC
  2. ;    QEDPCIO.A -- trimmed for QED
  3.  
  4.         dseg
  5. ;    In this implementation, all special and function keys are translated
  6. ;    to the following values.
  7.  
  8. ;/* control key translations */
  9. up_char        equ    30
  10. down_char    equ    31
  11. left_char    equ    29
  12. right_char    equ    28
  13. bol_char    equ    200
  14. eol_char    equ    201
  15. pageup_char    equ    202
  16. pagedown_char    equ    203
  17. bof_char    equ    204
  18. eof_char    equ    205
  19. Ins_char    equ    206
  20. Del_char    equ    207
  21. NextWord_char    equ    208
  22. PrevWord_char    equ    209
  23.  
  24. M1        equ    210
  25. M2        equ    211
  26. M3        equ    212
  27. M4        equ    213
  28. M5        equ    214
  29. M6        equ    215
  30. M7        equ    216
  31. M8        equ    217
  32. M9        equ    218
  33. M10        equ    219
  34. ;    the table that is used to make the translation
  35.  
  36. convert:
  37.         db    72, up_char
  38.         db    80, down_char
  39.         db    75, left_char
  40.         db    77, right_char
  41.         db    71, bol_char
  42.         db    79, eol_char
  43.         db    73, pageup_char
  44.         db    81, pagedown_char
  45.         db    77H, bof_char
  46.         db    75H, eof_char
  47.         db    82, Ins_char
  48.         db    83, Del_char
  49.         db    115, PrevWord_char
  50.         db    116, NextWord_char
  51.         db    59, M1
  52.         db    60, M2
  53.         db    61, M3
  54.         db    62, M4
  55.         db    63, M5
  56.         db    64, M6
  57.         db    65, M7
  58.         db    66, M8
  59.         db    67, M9
  60.         db    68, M10
  61.         db    0, 255 ; illegal character
  62.  
  63. ;    equates for bios interface.
  64.  
  65. ;    the interrupt and codes for the screen interface interrupt.
  66.  
  67. video        equ    10h        ;interrupt for dealing with screen
  68.  
  69. mode        equ    0        ;code for setting new screen mode
  70. curtype        equ    1        ;code for setting new cursor type
  71. setcur        equ    2        ;code for addressing cursor
  72. readcur        equ    3        ;code for reading cursor location
  73. readlp        equ    4        ;code for reading light pen position
  74. setpage        equ    5        ;code to select active page
  75. scrollup    equ    6        ;code to scroll screen up
  76. scrolldn    equ    7        ;code to scroll screen nown
  77. readch        equ    8        ;code to read a character from screen
  78. writeach    equ    9        ;code to write char and attributes
  79. writech        equ    10        ;code to write character only
  80. setpal        equ    11        ;code to set new setpal or border
  81. wdot        equ    12        ;code to write a dot
  82. rdot        equ    13        ;code to read a dot
  83. wtty        equ    14        ;code to write as if teletype
  84. state        equ    15        ;code to find current screen status
  85.  
  86.  
  87.  
  88. ;    the interrupt and codes for the keyboard interface.
  89.  
  90. keyboard    equ    16h        ;interrupt 16 to deal with keyboard
  91.  
  92. cicode        equ    0        ;code for reading a character
  93. cstscode    equ    1        ;code for keyboard status
  94.  
  95.  
  96.  
  97.  
  98. ;    caution: must change column number if 40 column mode
  99.  
  100. crt_cols    equ    80
  101.  
  102. ;    variables available to a C88 program
  103.  
  104.         public    scr_cols_, scr_rows_, scr_scrollup_, scr_scrolldown_    
  105.         public    scr_mode_,scr_page_,scr_attr_,scr_window_top_
  106.  
  107. scr_cols_:    dw    crt_cols    ;current number of columns
  108.  
  109. ;    note- make 25 for ms-dos and 24 for cp/m as cp/m steals the bottom
  110. ;    line.
  111. scr_rows_:    dw    25        ;current number of rows
  112. scr_mode_    db    0        ;current screen mode
  113. scr_page_    db    0        ;current page
  114. scr_attr_    db    7        ;current attributes for screen
  115.                     ;7 is white letters on black
  116. scr_window_top_    db    2        ;first line to scroll
  117.  
  118. ;    variables needed by SEE. Not used here.
  119. scr_scrollup_:    db    0        ;zero if scrollup leaves top line alone
  120. scr_scrolldown_:db    0        ;zero if scroll down supported
  121.  
  122.  
  123.  
  124.         cseg
  125.  
  126. ;    SCR_SETUP_    scr_setup must be called before any use of any
  127. ;            other routine unless the starting mode is 80X25
  128. ;            character mode (3,4 or 7). Must be called for monocrome
  129. ;            (mode 7) for scr_curson to set a proper cursor.
  130.  
  131. ;            Usage:    scr_setup();
  132.  
  133.         public    scr_setup_
  134. scr_setup_:    push    bp
  135.         mov    ah,state        ;get current state
  136.         int    video
  137.         mov    scr_mode_,al        ;current mode
  138.         mov    cl,ah            ;make cols a word
  139.         mov    ch,0
  140.         mov    scr_cols_,cx        ;40 or 80 columns
  141.         mov    scr_page_,bh
  142.         mov    scr_attr_,7        ;set to white chars on black
  143.         cmp    al,4            ;see if a character mode
  144.         jc    got_attr
  145.         cmp    al,7            ;7 is for graphics mode
  146.         jz    got_attr
  147.         mov    scr_attr_,0        ;attribute is zero in graphics
  148. got_attr:    mov    ah,0            ;return int containing mode
  149.         pop    bp
  150.         ret
  151.  
  152. ;    SCR_ROWCOL_        sets cursor at any location.
  153.  
  154. ;                Usage:    scr_rowcol(new row, new column);
  155.  
  156.         public    scr_rowcol_
  157. scr_rowcol_:                ; move cursor to x,y
  158.         push    bp        ; save from bios
  159.         mov    bp,sp
  160.         mov    dx,[bp+6]    ; column
  161.         mov    ax,[bp+4]    ; row
  162.         mov    dh,al
  163.         mov    bh,scr_page_    ; force page zero
  164.         mov    ah,setcur    ; set cursor location
  165.         int    video        ; call bios
  166.         pop    bp
  167.         ret
  168.  
  169.  
  170. ;    SCR_CLRL_        clear rest of line.
  171.  
  172. ;                Usage:        scr_clrl();
  173.  
  174.         public    scr_clrl_        
  175. scr_clrl_:                ; clear rest of line
  176.         push    bp
  177.         mov    bh,scr_page_
  178.         mov    ah,readcur    ;see where we are
  179.         int    video
  180.         mov    cl,byte scr_cols_    ;calc how many chars left in line
  181.         sub    cl,dl        ;number left
  182.         mov    ch,0        ;number of blanks needed
  183.         mov    al,' '        ;write blanks
  184.         mov    bl,scr_attr_    ;normal attributes
  185.         mov    bh,scr_page_    ;page number
  186.         mov    ah,writeach    ;write the blanks
  187.         int    video
  188.         pop    bp
  189.         ret
  190.  
  191.  
  192. ;    SCR_CLS_        clear rest of screen.
  193.  
  194. ;                Usage:    scr_cls();
  195.  
  196.         public    scr_cls_
  197. scr_cls_:                    ; clear rest of screen
  198.         push    bp
  199.         call    scr_clrl_    ;clear rest of line
  200.         mov    ah,readcur    ;see where we are
  201.         mov    bh,scr_page_
  202.         int    video
  203.         mov    al,0        ;ask for a clear window
  204.         mov    ch,dh        ;current row
  205.         inc    ch        ;+1
  206.         cmp    ch,byte scr_rows_;see if in last line
  207.         jz    cleared        ;all done
  208.         mov    cl,0        ;first column
  209.         mov    dh,byte scr_rows_;24 is the last line
  210.         dec    dh
  211.         mov    dl,byte scr_cols_    ;clear entire width
  212.         dec    dl        ;last column is width-1
  213.         mov    bh,scr_attr_    ;attributes for new blanks
  214.         mov    ah,scrollup    ;ask for a scrollup to clear
  215.         int    video        ;do the clear
  216. cleared:    pop    bp
  217.  
  218.         ret
  219.  
  220.  
  221. ;    SCR_SCRUP_        Scroll the screen up. The window is scrolled
  222. ;                up nline lines. A zero nline will clear the
  223. ;                window. Top left of the screen in 0,0.
  224.  
  225. ;            Usage: scr_scrup(nline,fromrow,fromcol,torow,tocol);
  226.  
  227.         public    scr_scrup_
  228. scr_scrup_:    push    bp
  229.         mov    bp,sp
  230.         mov    al,[bp+4]    ;number of lines
  231.         mov    ch,[bp+6]    ;starting row
  232.         mov    cl,[bp+8]    ;starting column
  233.         mov    dh,[bp+10]    ;ending row
  234.         mov    dl,[bp+12]    ;ending column
  235.         mov    bh,scr_attr_    ;current attribute
  236.         mov    ah,scrollup
  237.         int    video        ;do the scroll
  238.         pop    bp
  239.         ret
  240.  
  241.  
  242. ;    SCR_SCRDN_        scroll the screen down. the window is scrolled
  243. ;                down nline lines. A zero nline will clear the
  244. ;                window. Top left of the screen in 0,0.
  245.  
  246. ;            Usage: scr_scrdn(nline,fromrow,fromcol,torow,tocol);
  247.  
  248.         public    scr_scrdn_
  249. scr_scrdn_:    push    bp
  250.         mov    bp,sp
  251.         mov    al,[bp+4]    ;number of lines
  252.         mov    ch,[bp+6]    ;starting row
  253.         mov    cl,[bp+8]    ;starting column
  254.         mov    dh,[bp+10]    ;ending row
  255.         mov    dl,[bp+12]    ;ending column
  256.         mov    bh,scr_attr_    ;current attribute
  257.         mov    ah,scrolldn
  258.         int    video        ;do the scroll
  259.         pop    bp
  260.         ret
  261.